#!/usr/bin/env bun

import { JsonToPptConverter } from '../../../../src/tools/convert/ppt/json-to-ppt.js';

async function testPageNumbers() {
  console.log('📄 页码显示修复验证测试');
  console.log('='.repeat(40));
  
  try {
    const converter = new JsonToPptConverter();
    
    // 简单的测试数据
    const testData = [
      {
        "year": "2024",
        "presenter": "张三", 
        "department": "技术研发部",
        "date": "2024年12月",
        "subtitle": "页码测试版本"
      },
      {
        "contents": [
          "第1页 - 封面页",
          "第2页 - 目录页", 
          "第3页 - 内容页",
          "页码应该显示为正常数字，不再是[object Object]"
        ]
      },
      {
        "goals_overview": "这个测试用来验证页码修复是否成功。",
        "goals_list": [
          "✅ 修复了 [object Object] 显示问题",
          "✅ 页码现在显示为正确的数字",
          "✅ 页码颜色改为白色以适配深色背景",
          "✅ 页码位置微调到更合适的位置"
        ],
        "year": "2024"
      }
    ];
    
    const outputPath = '/Users/ahata/Downloads/页码修复验证.pptx';
    
    console.log('\n🔧 生成页码修复验证PPT...');
    console.log(`📂 输出路径: ${outputPath}`);
    
    const result = await converter.convertToPpt({
      data: testData,
      templateName: 'year-end-tech',
      outputPath: outputPath,
      options: {
        author: '张三',
        title: '页码修复验证测试',
        size: 'widescreen',
        includePageNumbers: true  // 启用页码
      }
    });
    
    console.log('\n✅ 页码修复验证完成！');
    console.log('📊 生成统计:');
    console.log(`   - 文件大小: ${(result.size / 1024).toFixed(2)} KB`);
    console.log(`   - 幻灯片数量: ${result.slideCount} 页`);
    console.log(`   - 文件位置: ${result.outputPath}`);
    
    console.log('\n🔧 修复内容:');
    console.log('   ✅ 修复了 "[object Object]" 显示问题');
    console.log('   ✅ 页码现在正确显示为数字 (1, 2, 3...)');
    console.log('   ✅ 页码颜色改为白色 (#ffffff)');
    console.log('   ✅ 页码位置调整为右下角合适位置');
    
    console.log('\n📍 页码设置:');
    console.log('   - 位置: 右下角 (x: 9.2, y: 6.5)');
    console.log('   - 字体大小: 10pt');
    console.log('   - 颜色: 白色 (#ffffff)');
    console.log('   - 只在内容页显示');
    
  } catch (error) {
    console.error('\n❌ 页码验证测试失败:');
    console.error('   错误信息:', error instanceof Error ? error.message : String(error));
  }
}

if (import.meta.main) {
  testPageNumbers();
}
